From eea0f62a1f6712f10afe47635b80a061505d2d2f Mon Sep 17 00:00:00 2001
From: Romain Naour <romain.naour@openwide.fr>
Date: Sat, 17 Jan 2015 18:33:37 +0100
Subject: [PATCH 1/2] Allow CFLAGS/CPPFLAGS to be completed from the
 environment

Buildroot passes its own CPPFLAGS and CFLAGS in the environment, so
the CFLAGS += and CPPFLAGS += statements in gnu-efi Makefile have no
effect. Change these to override <VARIABLE> += so that they extend the
flags passed by Buildroot.

[Romain:
 - rebase on top of 3.0.1 release]
[Bernd:
 - rebase on top of 3.0.5 release]
[Benoît:
 - rebase on top of 3.0.6 release]

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Romain Naour <romain.naour@openwide.fr>
Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
Signed-off-by: Benoît Allard <benoit.allard@greenbone.net>
---
 Make.defaults |   22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/Make.defaults b/Make.defaults
index 51bd7d8..7d7e8e7 100755
--- a/Make.defaults
+++ b/Make.defaults
@@ -85,14 +85,14 @@ OBJDIR       := $(TOPDIR)/$(ARCH)
 #
 
 # Arch-specific compilation flags
-CPPFLAGS += -DCONFIG_$(ARCH)
+override CPPFLAGS += -DCONFIG_$(ARCH)
 
 ifeq ($(ARCH),ia64)
-  CFLAGS += -mfixed-range=f32-f127
+  override CFLAGS += -mfixed-range=f32-f127
 endif
 
 ifeq ($(ARCH),ia32)
-  CFLAGS += -mno-mmx -mno-sse
+  override CFLAGS += -mno-mmx -mno-sse
   ifeq ($(HOSTARCH),x86_64)
     ARCH3264 = -m32
   endif
@@ -109,19 +109,19 @@ ifeq ($(ARCH),x86_64)
                                  && [ $(GCCMINOR) -ge "7" ] ) ) \
                           && echo 1)
   ifeq ($(GCCNEWENOUGH),1)
-    CPPFLAGS += -DGNU_EFI_USE_MS_ABI -maccumulate-outgoing-args --std=c11
+    override CPPFLAGS += -DGNU_EFI_USE_MS_ABI -maccumulate-outgoing-args --std=c11
   else ifeq ($(USING_CLANG),clang)
-    CPPFLAGS += -DGNU_EFI_USE_MS_ABI --std=c11
+    override CPPFLAGS += -DGNU_EFI_USE_MS_ABI --std=c11
   endif
 
-  CFLAGS += -mno-red-zone
+  override CFLAGS += -mno-red-zone
   ifeq ($(HOSTARCH),ia32)
     ARCH3264 = -m64
   endif
 endif
 
 ifeq ($(ARCH),mips64el)
-  CFLAGS += -march=mips64r2
+  override CFLAGS += -march=mips64r2
   ARCH3264 = -mabi=64
 endif
 
@@ -142,7 +142,7 @@ export LIBGCC=$(shell $(CC) $(ARCH3264)
 endif
 
 ifeq ($(ARCH),arm)
-CFLAGS += -marm
+override CFLAGS += -marm
 endif
 
 # Generic compilation flags
@@ -152,15 +152,15 @@ INCDIR  += -I$(SRCDIR) -I$(TOPDIR)/inc -
 # Only enable -fpic for non MinGW compilers (unneeded on MinGW)
 GCCMACHINE := $(shell $(CC) -dumpmachine)
 ifneq (mingw32,$(findstring mingw32, $(GCCMACHINE)))
-  CFLAGS += -fpic
+  override CFLAGS += -fpic
 endif
 
 ifeq (FreeBSD, $(findstring FreeBSD, $(OS)))
-CFLAGS  += $(ARCH3264) -g -O2 -Wall -Wextra -Werror \
+override CFLAGS  += $(ARCH3264) -g -O2 -Wall -Wextra -Werror \
            -fshort-wchar -fno-strict-aliasing \
            -ffreestanding -fno-stack-protector
 else
-CFLAGS  += $(ARCH3264) -g -O2 -Wall -Wextra -Werror \
+override CFLAGS  += $(ARCH3264) -g -O2 -Wall -Wextra -Werror \
            -fshort-wchar -fno-strict-aliasing \
            -fno-merge-all-constants -ffreestanding -fno-stack-protector \
            -fno-stack-check
-- 
2.11.0

